import request from '@/utils/request'

export default class Approval {
  static getApprovalList(data: any) {
    return request({
      url: `/user/process/instance/${data.page}/${data.pageSize}`,
      method: 'put',
      data
    })
  }
  // 获取审批信息
  static getInformation(id: any) {
    return request({
      url: `/user/process/instance/getById/${id}`
    })
  }
  static getReviewHistory(id: any) {
    return request({
      url: `/approvals/flows/${id}`
    })
  }
  static process(data: any) {
    return request({
      url: '/approvals/process',
      method: 'post',
      data
    })
  }
  static getSetState(params: any) {
    return request({
      url: '/approvals/setting',
      params
    })
  }
  // 保存状态
  static saveSetState(data: any) {
    return request({
      url: '/approvals/setting',
      method: 'put',
      data
    })
  }
  // 获取流程详情
  static getApprovalsDetail(id: any) {
    return request({
      url: `/user/process/instance/${id}`
    })
  }
  // 获取流程详情
  static getApprovalsTaskDetail(id: any) {
    return request({
      url: `/user/process/instance/tasks/${id}`
    })
  }
  // 下载图片
  static downImg(picture_id: any) {
    return request({
      url: `//user/process/buss/showBussImgById/${picture_id}`
    })
  }
  // 获取流程列表
  static getFlowList(params: any) {
    return request({ url: `/user/process/definition`, params })
  }
  static suspend(params: any) {
    return request({
      url: `/user/process/suspend/${params.processKey}`,
      params
    })
  }
  static startProcess(data: any) {
    return request({
      url: `/user/process/startProcess`,
      data,
      method: 'post'
    })
  }
  static applyeLave(data: any) {
    return request({
      url: `/user/process_leave/startProcess`,
      data,
      method: 'post'
    })
  }

  // 驳回
  static approvalsReject(data: any) {
    return request({
      url: `/user/approvals/${data.id}/reject`,
      method: 'put',
      data
    })
  }
  // 删除
  static approvalsDel(id: any) {
    return request({
      url: `/user/approvals/${id}`,
      method: 'delete'
    })
  }
  // 同意
  static approvalsPass(data: any) {
    return request({
      url: '/user/process/instance/commit',
      method: 'put',
      data
    })
  }
  static applyDimission(data: any) {
    return request({
      url: '/user/process_dimission/startProcess',
      method: 'post',
      data
    })
  }
  static applyOvertime(data: any) {
    return request({
      url: '/user/process_overtime/startProcess',
      method: 'post',
      data
    })
  }
  static staticApprovals(data: any) {
    return request({
      url: `/approvals/static/${data.month}`,
      data
    })
  }

  static updateUser(data: any) {
    return request({
      url: `/sys/user/${data.id}`,
      method: 'put',
      data
    })
  }
}
